#define _CRT_SECURE_NO_WARNINGS  1
#include<stdio.h>
int main()
{
    long long int n = 0;
    scanf("%lld", &n);
    long long int arr[1000] = { 0 };
    long long int i = 0;
    for (i = 0; i < n; i++)
    {
        scanf("%lld", &arr[i]);
    }
    long long int arr1[1000] = { 0 };
    long long int arr2[1000] = { 0 };
    long long int k = 1;
    long long int count = 1;
    const long long mod = 1000000007;
    long long int max = 0;
    arr1[0] = 1;
    while (1)
    {
        if (arr1[k - 1] % 2 == 1)
        {
            if (arr[k - 1] < k)
            {
                count = count + (arr2[k - 1] - arr2[arr[k - 1] - 1]+mod)%mod;
                count = count % mod;
            }
            else
            {
                k = arr[k - 1];
            }
        }
        else
        {
            if (k > max)
            {
                arr2[k] = count;
                max = k;
            }
            k += 1;
        }
        if (k == n + 1)
        {
            break;
        }
        arr1[k - 1] += 1;
        count += 1;
        count = count % mod;
    }
    printf("%lld", count);
    return 0;
}